home *** CD-ROM | disk | FTP | other *** search
/ 100 Plus Great Games 2 / 100PLUSV2.BIN / games / MinerX.dxr / 00034_Alien Scripts.ls < prev    next >
Encoding:
Text File  |  2002-01-25  |  4.9 KB  |  174 lines

  1. on setAlienConstants
  2.   global alienData, alienSO, maxAliens, laserSO, maxLasers
  3.   alienSO = 400
  4.   maxAliens = 1
  5.   laserSO = 500
  6.   maxLasers = 25
  7. end
  8.  
  9. on initializeAliens
  10.   global alienData, alienSO, maxAliens, wTest
  11.   alienData = []
  12.   repeat with wItem = 1 to maxAliens
  13.     wSprite = wItem + alienSO - 1
  14.     add(alienData, [0, point(random(5800), random(4400))])
  15.     puppetSprite(wSprite, 1)
  16.     set the member of sprite wSprite to "Alien1"
  17.     set the loc of sprite wSprite to point(-50, -50)
  18.     set the ink of sprite wSprite to 36
  19.   end repeat
  20.   wTest = 0
  21. end
  22.  
  23. on initializelasers
  24.   global laserData, laserSO, maxLasers, wTest
  25.   laserData = []
  26.   repeat with wItem = 1 to maxLasers
  27.     wSprite = wItem + laserSO - 1
  28.     add(laserData, [0, point(random(5800), random(4400))])
  29.     puppetSprite(wSprite, 1)
  30.     set the member of sprite wSprite to "Alien1"
  31.     set the loc of sprite wSprite to point(-50, -50)
  32.     set the ink of sprite wSprite to 36
  33.   end repeat
  34.   wTest = 0
  35. end
  36.  
  37. on addAlien
  38.   global alienData, alienSO, maxAliens, wTest
  39.   case random(2) of
  40.     1:
  41.       spawnloc = point([0, 5800][random(2)], random(4400))
  42.     2:
  43.       spawnloc = point(random(5800), [0, 4400][random(2)])
  44.   end case
  45.   validSlot = 0
  46.   repeat with wS = 1 to maxAliens
  47.     if validSlot = 0 then
  48.       if alienData[wS][1] = 0 then
  49.         validSlot = wS
  50.       end if
  51.     end if
  52.   end repeat
  53.   if validSlot <> 0 then
  54.     alienData[validSlot] = [1, spawnloc, random(360), random(360), 100]
  55.   end if
  56. end
  57.  
  58. on addLaser spawnloc, spawnAim
  59.   global laserData, laserSO, maxLasers, wTest
  60.   validSlot = 0
  61.   repeat with wS = 1 to maxLasers
  62.     if validSlot = 0 then
  63.       if laserData[wS][1] = 0 then
  64.         validSlot = wS
  65.       end if
  66.     end if
  67.   end repeat
  68.   if validSlot <> 0 then
  69.     laserData[validSlot] = [1, spawnloc, spawnAim]
  70.     sprite(laserSO + validSlot).rotation = spawnAim
  71.   end if
  72. end
  73.  
  74. on runAliens
  75.   global alienData, alienSO, maxAliens, bgOffset, wTest, playerData, totalAliens, playerScore
  76.   totalAliens = 0
  77.   repeat with wAlien = 1 to maxAliens
  78.     if alienData[wAlien][1] = 1 then
  79.       totalAliens = totalAliens + 1
  80.       wSprite = wAlien + alienSO - 1
  81.       aLoc = alienData[wAlien][2]
  82.       mloc = playerData[2]
  83.       turnAdjust = random(12) - 6
  84.       moveAim = alienData[wAlien][3]
  85.       moveDist = 5
  86.       locY = integer(cos(moveAim * PI / 180) * -moveDist)
  87.       locX = integer(sin(moveAim * PI / 180) * moveDist)
  88.       aLoc = aLoc + point(locX, locY)
  89.       if locX > 0 then
  90.         if aLoc[1] > 6000 then
  91.           aLoc[1] = -200
  92.           alienData[wAlien][3] = random(90) + 45
  93.         end if
  94.       else
  95.         if aLoc[1] < -200 then
  96.           aLoc[1] = 6000
  97.           alienData[wAlien][3] = random(90) + 180 + 45
  98.         end if
  99.       end if
  100.       if locY > 0 then
  101.         if aLoc[2] > 4600 then
  102.           aLoc[2] = -200
  103.           alienData[wAlien][3] = random(90) + 45 + 90
  104.         end if
  105.       else
  106.         if aLoc[2] < -200 then
  107.           aLoc[2] = 4600
  108.           alienData[wAlien][3] = (random(90) + 45 + 270) mod 360
  109.         end if
  110.       end if
  111.       alienData[wAlien][2] = aLoc
  112.       maxTimer = (5000 - playerScore) / 50
  113.       if alienData[wAlien][5] > 0 then
  114.         alienData[wAlien][5] = alienData[wAlien][5] - 1
  115.       else
  116.         alienData[wAlien][5] = maxTimer
  117.         addLaser(alienData[wAlien][2], alienData[wAlien][4] + [0, 90, 180, 270][random(4)])
  118.         playSound("Laser SFX", 4)
  119.       end if
  120.       set the loc of sprite wSprite to (aLoc / 10) + bgOffset
  121.       alienData[wAlien][4] = alienData[wAlien][4] + 1
  122.       if alienData[wAlien][4] > 5 then
  123.         alienData[wAlien][4] = 1
  124.       end if
  125.       set the member of sprite wSprite to "Enimy" & string(alienData[wAlien][4])
  126.     end if
  127.   end repeat
  128. end
  129.  
  130. on runLasers
  131.   global laserData, laserSO, maxLasers, bgOffset, wTest, playerData, totalLasers
  132.   totalLasers = 0
  133.   repeat with wLaser = 1 to maxLasers
  134.     if laserData[wLaser][1] = 1 then
  135.       totalLasers = totalLasers + 1
  136.       wSprite = wLaser + laserSO - 1
  137.       aLoc = laserData[wLaser][2]
  138.       mloc = playerData[2]
  139.       turnAdjust = random(12) - 6
  140.       moveAim = laserData[wLaser][3]
  141.       moveDist = 50
  142.       locY = integer(cos(moveAim * PI / 180) * -moveDist)
  143.       locX = integer(sin(moveAim * PI / 180) * moveDist)
  144.       aLoc = aLoc + point(locX, locY)
  145.       terminate = 0
  146.       if locX > 0 then
  147.         if aLoc[1] > 6000 then
  148.           terminate = 1
  149.         end if
  150.       else
  151.         if aLoc[1] < -200 then
  152.           terminate = 1
  153.         end if
  154.       end if
  155.       if locY > 0 then
  156.         if aLoc[2] > 4600 then
  157.           terminate = 1
  158.         end if
  159.       else
  160.         if aLoc[2] < -200 then
  161.           terminate = 1
  162.         end if
  163.       end if
  164.       if terminate = 1 then
  165.         laserData[wLaser][1] = 0
  166.       end if
  167.       laserData[wLaser][2] = aLoc
  168.       set the member of sprite wSprite to "Alien Laser"
  169.       sprite(wSprite).rotation = moveAim
  170.       set the loc of sprite wSprite to (aLoc / 10) + bgOffset
  171.     end if
  172.   end repeat
  173. end
  174.